import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import os
ymn12 = []
yx13 = []
yl = []
ylmn = []

names = 'metrics/mAP_0.5:0.95'
file_name = 'ymn12-exp13.csv'
io = pd.read_csv(file_name)
df1 = pd.DataFrame(io)
for index, row in df1.iterrows():
    ymn12.append(float(row[names]))


file_name = 'yx-exp12.csv'
io = pd.read_csv(file_name)
df1 = pd.DataFrame(io)
for index, row in df1.iterrows():
    yx13.append(float(row[names]))

file_name = 'ylmn.csv'
io = pd.read_csv(file_name)
df1 = pd.DataFrame(io)
for index, row in df1.iterrows():
    ylmn.append(float(row[names]))

file_name = 'yl.csv'
io = pd.read_csv(file_name)
df1 = pd.DataFrame(io)
for index, row in df1.iterrows():
    yl.append(float(row[names]))

mins = min(min(len(ymn12), len(yx13)), min(len(ylmn), len(yl)))
print(mins)

ymn12 = ymn12[:mins]
yx13 = yx13[:mins]
ylmn = ylmn[:mins]
yl = yl[:mins]

# print("ymn12 = %.5f yx13 = %.5f  ylmn = %.5f  yl = %.5f" % (max(ymn12), max(yx13), max(ylmn), max(yl)))

names = names.lstrip()
names = names.replace('/', '-')
y = ymn12 + yx13 + ylmn + yl
epoch = [i for i in range(300)] * 4
Types = ["yxmn" for i in range(300)] + ["yx" for i in range(300)] + ["ylmn" for i in range(300)] + ["yl" for i in range(300)]
color_palette = ['red', 'blue', 'yellow', 'purple']
datas = pd.DataFrame({names: y, "epoch": epoch, "class": Types})
sns.scatterplot(x="epoch", y=names, hue="class", data=datas, palette=color_palette)

nums = 50
plt.legend(fontsize=nums)
plt.xlabel("epoch", fontsize=nums)
plt.ylabel(names, fontsize=nums)
plt.title(names + " ", fontsize=nums)
plt.show()


